package com.ophiux.common.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Properties;
import java.util.ResourceBundle;

public class PropertiesUtil {
	public static Properties getPropertiesByFilePath(String filePath)
			throws IOException {
		Properties prop = new Properties();

		File file = new File(filePath);

		FileInputStream is = new FileInputStream(file);

		prop.load(is);

		return prop;
	}

	public static ResourceBundle getResourceBundle(String fileName) {
		ResourceBundle bundle = ResourceBundle.getBundle(fileName);
		return bundle;
	}

	public static String getpopertyValue(ResourceBundle bundle, String property) {
		String value = bundle.getString(property);
		try {
			value = new String(value.getBytes("ISO-8859-1"), "utf-8");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return value;
	}

	public static void main(String[] args) {
		ResourceBundle bundle = getResourceBundle("config");
	}
}